<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>login</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/element-ui@2.15.13/lib/theme-chalk/index.min.css"/>
    <script src="https://cdn.jsdelivr.net/npm/jquery@2.2.4/dist/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.7.14/dist/vue.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/element-ui@2.15.13/lib/index.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/jquery.cookie@1.4.1/jquery.cookie.min.js"></script>
<head>

    <style type="text/css">

        .login-wrap {
            box-sizing: border-box;
            width: 100%;
            height: 100%;
            padding-top: 10%;
             /* background-color: #112346; */
            background-repeat: no-repeat;
            background-position: center right;
            background-size: 100%;
        }
        /*#button-login{*/
        /*    background: #fff url("/button.png");*/
        /*}*/
        .login-container {
            border-radius: 10px;
            margin: 0px auto;
            margin-top: 80px;
            width: 350px;
            padding: 30px 35px 15px 35px;
            background: #fff;
            border: 1px solid #eaeaea;
            text-align: left;
            box-shadow: 0 0 20px 2px rgba(0, 0, 0, 0.1);
        }
        .title {
            margin: 0px auto 40px auto;
            text-align: center;
            color: #505458;
        }
    </style>
<!--    <style>-->
<!--        body {-->
<!--            /*background-image: url('/zaocan.jpg');*/-->

<!--        }-->
<!--    </style>-->
</head>
<body>
<el-form class="login-container" id="app">
    <h1 class="title">欢迎登录</h1>
    <el-form-item>
        <el-input type="text" v-model="loginForm.name" placeholder="用户账号" autocomplete="off"></el-input>
    </el-form-item>
    <el-form-item>
        <el-input type="password" v-model="loginForm.password" placeholder="用户密码" autocomplete="off"></el-input>
    </el-form-item>
    <el-form-item>
        <el-button id="button-login" type="primary" @click="toLogin" style="width: 100%;">点击登录</el-button>
    </el-form-item>
    <el-row style="text-align: center;margin-top: -10px;">
        <el-link type="primary" @click="doRegister()">注册账号</el-link>
<!--        <el-link type="primary" @click="">忘记密码</el-link>-->
    </el-row>
</el-form>
<script>
    console.log(".........login...........")
    new Vue({
        el: "#app"
        ,
        data: {
            loginForm:{
                name:"",
                password:""
            }
        }
        ,
        methods: {
            toLogin(){
                console.log(this.loginForm)

                $.post("/user/login",this.loginForm,function (data) {
                    console.log(data);
                    if(!data.error){
                        $.cookie("token", data.token, {path: "/"});
                        $.cookie("account", data.account, {path: "/"});
                        $.cookie("checkId", data.uuid, {path: "/"});
                        location.href="/";
                    }else {
                        alert(data.error)
                        location.href="/toLogin";
                    }
                })
            }
            ,
            doRegister:function(){
                location.href="/toRegister";
            }
        }
        ,
        created(){

        }

    });

</script>

</body>
</html>